package com.lucene.demo;

import java.io.InputStream;
import java.io.PrintWriter;
import java.io.StringWriter;

import org.apache.poi.hdf.extractor.WordDocument;

public class Test {
	public static void main(String[] args) throws Exception {
		/*Integer i = 4;
		System.out.println(getDocument(new FileInputStream(new File("c:/a.doc"))));*/
		int i=0;
		int j=0;
		for (i=0;j<6;i++,j++) {
			System.out.println(i+j);
		}
	}

	public static String getDocument(InputStream is) throws Exception {
		String bodyText = null;
		try {
			WordDocument wd = new WordDocument(is);
			StringWriter docTextWriter = new StringWriter();
			wd.writeAllText(new PrintWriter(docTextWriter));
			docTextWriter.close();
			bodyText = docTextWriter.toString();
		} catch (Exception e) {
			throw new Exception("Cannot extract text from a Word document", e);
		}
		if ((bodyText != null) && (bodyText.trim().length() > 0)) {

			return bodyText;
		}
		return null;
	}

}
